package net.toocruel.iqismart.service.helper;

import net.toocruel.iqismart.entity.rbac.User;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @Description
 * @Auther sty
 * @createTime 2018/5/12 下午9:03
 */
public class UserHelper {
    public static User getCurrentUser(){
        try {
            Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
            if(principal instanceof User){
                return (User) principal;
            }
        } catch (Exception e) {
        }

        return null;
    }
}
